<template>
	<div class="bg">
		<goback title="回收去向"></goback>
		<div class="card shadow">
			<div class="card_title">去向调研</div>
			<div class="collect_container">
				<textarea v-model="result" placeholder="在此输入您的回收去向,分享给其他企业作为解决方案,(如果是多用途,请使用逗号分割)"></textarea>
				<div class="card_title tags_title">标签选择</div>
				<div class="card_context tags">
					<div v-for="(item,index) in normal_tags" @click="AddTags(item)">{{item}}</div>
				</div>
				<button class="left_shadow" @click="submit_collectway">完成</button>
			</div>
		</div>
		<copyright></copyright>
	</div>
</template>

<script>
	export default {
		name: "collectway",
		data() {
			return {
				result:"",
				normal_tags: ['政府回收','制作饲料','秸秆工艺品','制造草席','秸秆还田','秸秆沼气','秸秆造纸','加工板材']
			};
		},
		mounted() {

		},
		methods: {
			submit_collectway(){
				let arr = this.result.split(',');
				this.axios.post(`${this.IP}/buyer_collect`, {
						token: this.getStorage('token'),
						ordernum: this.$route.query.ordernum,
						collectway: JSON.stringify(arr)
				}).then(res => {
					this.$toast.showMessage(res.data);
					this.tipOtherIfOnline(this.$route.query.ordernum);
					this.$router.go(-1);
				})
			},
			
			tipOtherIfOnline(e){
				const send_msg = JSON.stringify({
					action: 'update_order',
					data: {
						ordernum: this.$route.query.ordernum,
					}
				});
				this.$store.getters.getSocket.send(send_msg);
			},
			
			AddTags(item){
					
				if(this.result == ''){
					this.result=item
				}else{
					this.result+=','+item;
				}
			},
			
		}
	}
</script>

<style scoped>
.card{
	margin-top: 5vh;
}
.collect_container{
	width: 100%;
}
.collect_container textarea{
	width: 95%;
	height: 5vh;
	border: none;
	border: 1px solid #bfbfbf;
	padding: 1vw;
	margin: 1vw;
	border-radius: 20px;
}
.tags_title{
	margin-top: 5vw;
}
.collect_container button{
	margin-top: 10vw;
	margin-bottom: 5vw;
	width: 100%;
	padding: 3vw;
	border-radius: 20px;
	background: linear-gradient(to right, #f9d24f, #ffdc50);
}
.tags{
	margin-top: 2vw;
}
</style>